package com.kingdee.pda.ui.check_order;

import android.content.Context;

import com.example.basecommon.http.MyObserver;
import com.example.basecommon.http.RxHelper;
import com.example.basecommon.http.rxjava.BaseResponse;
import com.example.basecommon.http.rxjava.HttpUtils;
import com.example.basecommon.utils.ConstantUtil;
import com.kingdee.pda.Api;
import com.kingdee.pda.entity.CheckOrderListBean;

import java.util.HashMap;
import java.util.List;

public class CheckOrderListPresenter implements CheckOrderListContract.ICheckOrderPresenter{
    Context context;
    CheckOrderListContract.ICheckOrderView orderView;

    public CheckOrderListPresenter(Context context, CheckOrderListContract.ICheckOrderView orderView) {
        this.context = context;
        this.orderView = orderView;
    }



    @Override
    public void getCheckOrderList(String status, String billNo, long warehouseId, int pageSize, int pageIndex) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("warehouseid", warehouseId+"");
//        map.put("pageSize", pageSize);
//        map.put("pageIndex", pageIndex);
        map.put("billstatus", status);
        map.put("billno", billNo);
//        map.put("itemSkucode", billNo);

        MyObserver<List<CheckOrderListBean>> myObserver = new MyObserver<List<CheckOrderListBean>>(context) {

            @Override
            public void onSuccess(BaseResponse<List<CheckOrderListBean>> result) {
                orderView.getOrderSuccess(result.data);
            }

            @Override
            public void onFailure(BaseResponse result,String msg) {
                orderView.getOrderFailed(msg);
            }
        };

        HttpUtils.request(Api.class)
                .getCheckOrderList(ConstantUtil.CHECK_ORDER_LIST, map)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(myObserver);
    }

}
